import request from '@/utils/request'

export function list(params) {
  const res = request({
    url: 'api/dept',
    method: 'get',
    params
  })
  return res.then(response => {
    const list = response.content
    for (let i = 0; i < list.length; i++) {
      list[i].label = list[i].name
    }
    return response
  })
}

export function add(data) {
  return request({
    url: 'api/dept',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/dept',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/dept',
    method: 'put',
    data
  })
}

export default { add, edit, del, list }
